import React from 'react'
import {connect} from 'dva';
import {Table} from 'antd';

const ReplayList=({
  traderList=[],
  data=[],
  total=false,
})=>{
  const columns=traderList.map((item,i)=>({
    title: item.trader_name,
    dataIndex: `trader_${item.trader}`,
    key: `trader_${item.trader}`,
    width:100,
    render: (text, record) => text&&(Number(String(text).split('%')[0])>0?<span style={{color:'green'}}>{text}</span>:<span style={{color:'red'}}>{text}</span>)||'-'
  }))
  if(traderList.length){
    columns.unshift({
      title: '证券名称',
      dataIndex: 'stockname',
      key: 'stockname',
      width:100,
      // fixed: 'left'
    })
  }
  const myProps = {
    dataSource : total?data:data.filter(item=>item.stockname!='股票汇总'),
    columns:total?columns:columns.filter(item=>item.key!='trader_total'),
    rowKey:'key',
    pagination:false,
    scroll:{ y: document.body.clientHeight-360 }
  }
  return (
    <Table {...myProps}/>
  )
}

ReplayList.defaultProps={
  traderList:[],
  data:[],
}

export default ReplayList
